package com.proxyadvertise.parse;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.List;

public class ProxyIp {
	
	private static List<String> IP_LIST = new ArrayList<String>();
	
	public static void parse() throws Exception{
		
		String ipfile = ProxyIp.class.getResource( "/ip.txt" ).getPath();
		
		try {
			ipfile = URLDecoder.decode( ipfile, "utf-8" );
		} catch (UnsupportedEncodingException e1) {
			e1.printStackTrace();
		}
		
		FileReader fr=new FileReader( ipfile );
        BufferedReader br=new BufferedReader(fr);
        String line="";
        
        while ((line=br.readLine())!=null) {
            ProxyIp.IP_LIST.add( line.trim() );
        }
        br.close();
        fr.close();
        
	}
	
	public static List<String> getAllProxyIp(){
		return ProxyIp.IP_LIST;
	}
	
	public static void main(String[] args) {
		try {
			ProxyIp.parse();
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		System.out.println( ProxyIp.getAllProxyIp().size() );
	}
}
